﻿using System;
using System.Collections.Generic;

class MaxElementInPortion
{
    static void MaxInPortion(int[] array, int dimention)
    {
        Console.WriteLine("Enter the elements of the array:");
        for (int index = 0; index < dimention; index++)
        {
            Console.WriteLine("Enter element {0}:", index);
            array[index] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine();
        Console.WriteLine("The array you entered is:");
        for (int i = 0; i < dimention; i++)
        {
            Console.Write("{0,3}",array[i]);
        }
        Console.WriteLine();
        Console.WriteLine("From which index you want to explore the array for max element?");
        int position = int.Parse(Console.ReadLine());
        if (position < 0 || position > dimention)
        {
            Console.WriteLine("The number is not in range - (0 - {0})", dimention);
        }
        else
        {
            int maxElem = array[position];
            for (int j = position; j < dimention - 1; j++)
            {
                for (int x = j + 1; x < dimention; x++)
                {
                    if (array[x] > maxElem)
                    {
                        maxElem = array[x];
                    }
                }
            }
            Console.WriteLine("The biggest element in this portion is {0}", maxElem);
        }
       
    }

    static void Main()
    {
        Console.WriteLine("Enter the number of elements in the array:");
        int arrayLength = int.Parse(Console.ReadLine());
        int[] arrayOfInts = new int[arrayLength];
        MaxInPortion(arrayOfInts, arrayLength);
    }
}

